#include "mainwindow.h"
#include "ui_mainwindow.h"



MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    widget = new MainWidget(this);
    dialog = new SetRowColDialog(this);
    exportBrowser = new QTextBrowser(this);
    exportDialog = new QDialog(this);

    // 设置导出文本框界面
    QGridLayout* layout = new QGridLayout();
    layout->addWidget(exportBrowser);
    exportDialog->setLayout(layout);

    this->setCentralWidget(widget);

    // 连接事件
    connect(dialog, SIGNAL(signalRowColChanged(int,int)), widget, SLOT(slotSetRowCol(int,int)));
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_actionSetRowCol_triggered()
{
    dialog->exec();
}

void MainWindow::on_actionExport_triggered()
{
    QString str = widget->exportText(dialog->getRow(), dialog->getCol());
    exportBrowser->setText(str);
    exportDialog->exec();
}

void MainWindow::on_actionOutReverse_triggered()
{
    widget->setReverse(MainWidget::Reverse::OUT_REVERSE);
}

void MainWindow::on_actionAllReverse_triggered()
{
    widget->setReverse(MainWidget::Reverse::ALL_REVERSE);
}
